package com.mssh.login.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 熳殊沙华
 * @Date: 2023/09/21/23:30
 * @Description: 配置文件工具类
 */
@Configuration
public class PropertiesUtil {

    /**
     * RSA的公钥
     */
    @Value("${rsa.publicKey}")
    private String publicKey;

    /**
     * RSA的私钥
     */
    @Value("${rsa.privateKey}")
    private String privateKey;

    /**
     * 加解密开关
     */
    @Value("${rsa.isEncrypt}")
    private boolean isEncrypt;


    public static String getPublicKey() {
        PropertiesUtil propertiesUtil = (PropertiesUtil) SpringUtil.getBean("propertiesUtil");
        return propertiesUtil.publicKey;
    }

    public static String getPrivateKey() {
        PropertiesUtil propertiesUtil = (PropertiesUtil) SpringUtil.getBean("propertiesUtil");
        return propertiesUtil.privateKey;
    }

    public static boolean isEncrypt() {
        try {
            PropertiesUtil propertiesUtil = (PropertiesUtil) SpringUtil.getBean("propertiesUtil");
            return propertiesUtil.isEncrypt;
        }catch (Exception e){
            System.out.println(e);
        }
        return false;
    }
}
